$(function(){
	new Vue({
		el:'#shopListApp',
		data:{
			uploadUrl: "http://39.100.131.147:8888/goods/address/uploadFile",
			fullscreenLoading:false,
			fileAvatarList:[],
			form:{
				name:"",
				phoneNum:"",
			}
		},
		created:function(){
			  parent.vueData.$data.hreHtml = "../addPlartShop/index.html";
			  parent.vueData.activeIndex = "7";
			  parent.vueData.getLeftNav("7")
			  parent.vueData.$data.categoryIndex = 0
		},
		methods:{
			handleAvatarSuccess(res, file) {
				this.imageUrl = URL.createObjectURL(file.raw);
			},
			 handleChange(value) {
			        console.log(value);
			},
			beforeCourseRemove(file, fileList) {
				  let index = this.carouseImgUrl.findIndex( fileItem => {
				       return fileItem.url === file.url
				   })
				  this.carouseImgUrl.splice(index, 1)
				return true;
			},
			handleCoverExceed(files, fileList) {
				this.$message.warning("店铺logo只能上传一张图片")
			},
			handleCoverSuccess(response, file, fileList) {
				if (response.code == 100) {
					
					this.form.logoImg = response.result
					this.fileAvatarList.push({
						name: "店铺logo",
						url: response.result,
					})
				}
			},
			beforeAvaterRemove(file,fileList) {
				  let index = this.fileAvatarList.findIndex( fileItem => {
				       return fileItem.url === file.url
				   })
				  this.fileAvatarList.splice(index, 1)
				return true;
			},
			onClickAddShop(){
				if(stringEmpty(this.form.name)){
					this.$message.error("店铺名称不能为空");
					return;
				}
				else if (stringEmpty(this.form.phoneNum)){
					this.$message.error("店铺电话不能为空");
					return;
				}
				else if (stringEmpty(this.form.logoImg)){
					this.$message.error("店铺logo不能为空");
					return;
				}
				this.form.userPhone  = this.form.phoneNum;
				this.fullscreenLoading = true;
				axios({
					url: POSTURL.insertDealerShop,
					method: 'post',
					data: this.form
				}).then(response => {
					this.fullscreenLoading = false;
					if (response.data.code === 100) {
						this.$message({
							showClose: true,
							message: response.data.message,
							type: 'success'
						});
					} else {
						this.$message.error(response.data.message);
					}
				}).catch(error => {
					this.fullscreenLoading = false;
					console.log(error);
					this.$message.error('服务器出错!');
				})
				
			}
			
		}
	})
})